#include <bits/stdc++.h>
// 2025/02/03
// tag: 
// Author: Zhang Muen
using namespace std;

int missile[100001], dp[100001], cnt;

signed main()
{
    while (cin >> missile[++cnt])
        ;
    cnt--;
    int ans = 0;
    dp[0] = INT_MAX;
    for (int i = 1; i <= cnt; i++)
    {
        int l = 0, r = cnt + 1;
        while (l + 1 < r){
            int mid = (l + r) / 2;
            if (dp[mid] >= missile[i])
                l = mid ;
            else
                r = mid ;
        }
        if (l + 1 > ans)
            ans = l + 1;
        dp[l + 1] = missile[i];
    }
    cout << ans << endl;
    ans = 0;
    memset(dp, 0, sizeof(dp));
    dp[0] = INT_MIN;
    
    for (int i = 1; i <= cnt; i++) {
        if (missile[i] > dp[ans])
            dp[++ans] = missile[i];
        else {
            int l = 1, r = ans;
            while (l < r) {
                int mid = l + r >> 1;
                if (dp[mid] >= missile[i])
                    r = mid;
                else
                    l = mid + 1;
            }
            dp[l] = missile[i];
        }
    }
    cout << ans << endl;
    return 0;
}